package com.chenwut.threadDemo.waitandnotify02;

import java.util.concurrent.ArrayBlockingQueue;

/**
 * @author ChenPi
 * @since 2024/09/19 10:51
 */
public class ThreadDemo {
    public static void main(String[] args) {
        /**
         * 完成生产者和消费者（等待唤醒机制）的代码
         * 实现线程轮流交替执行的效果
         */
        ArrayBlockingQueue<String> queue = new ArrayBlockingQueue<>(1);

        Cook c = new Cook(queue);
        Foodie f = new Foodie(queue);

        c.setName("厨师");
        f.setName("吃货");

        c.start();
        f.start();
    }
}
